//
//  TF_CourseDownloadController.swift
//  TalkfunSDKDemo
//
//  Created by 邓盛明 on 2022/2/22.
//  Copyright © 2022 Talkfun. All rights reserved.
//

import UIKit


class TFdocDownloadController: UIViewController, TF_CourseDownLoadDetailDelegate {

    func checkCourseDetail(_ model: TFdoc) {
        if #available(iOS 9.0, *) {
            let vc = TFdocumentPreviewController.init()
          
            vc.urlStr = model.url;
        
            if model.localPath.count>0 {

                vc.localPath = model.localPath
                if self.navigationController != nil {
                   self.navigationController?.pushViewController(vc, animated: true)
                }else
                {
                    self.present(vc, animated: true)
                }
            }
          
        } else {
            // Fallback on earlier versions
        }
       
    }
    
   @objc public var courseDownView:TF_CourseDownLoadRoot!
    override func viewDidLoad() {
        super.viewDidLoad()

        self.courseDownView = TF_CourseDownLoadRoot.init(frame: self.view.bounds)
        self.courseDownView.backgroundColor = UIColor.white
        self.courseDownView.isEdit = true
        self.courseDownView.type = .large
        self.courseDownView.delegate = self
        self.view.addSubview(self.courseDownView)

        
    }
    
    // 控制器的view即将显示的时候调用
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        let arr:[TFdoc] = self.courseDownView.manager.getDownloadDocumentList()
        
        
        self.courseDownView.upCourseDownloadData(arr)
        
        self.courseDownView.setCourseDownManagerdelegate()
        
    }

}
